package net.apexes.demo.codegen.dslite.qvar;

import net.apexes.demo.codegen.dslite.entity.UserTemplate;
import net.apexes.demo.codegen.dslite.qvar.base.QEntityBase;
import net.wafo.dslite.core.info.ForeignKey;
import net.wafo.dslite.core.info.Index;

import net.wafo.dslite.core.dsl.*;

/**
 * QUserTemplate is a DSLite query type for UserTemplate
 * @see UserTemplate
 */
public class QUserTemplate extends QEntityBase<UserTemplate> {

    public static final QUserTemplate $ = new QUserTemplate("USER_TEMPLATE");

    public final StringColumn userId = varchar("USER_ID", 22).field("userId").notNull().build();

    public final StringColumn templateId = varchar("TEMPLATE_ID", 22).field("templateId").notNull().build();

    public class Indexs {

        public final Index constraintIndexF = index("CONSTRAINT_INDEX_F").column(userId).build();

        public final Index constraintIndexF6 = index("CONSTRAINT_INDEX_F6").column(templateId).build();

        public final Index primaryKeyF6 = index("PRIMARY_KEY_F6").unique().column(id).build();

    }

    public final Indexs ix = new Indexs();

    public class ForeignKeys {

        public final ForeignKey constraintF68 = foreignKey(userId, "AUTH_USER", "ID");

        public final ForeignKey constraintF68a = foreignKey(templateId, "TEMPLATE", "ID");

    }

    public final ForeignKeys fk = new ForeignKeys();

    public QUserTemplate(String tableName) {
        super(UserTemplate.class, tableName);
    }

    @Override
    public UserTemplate newEntity() {
        return new UserTemplate();
    }

    @Override
    public Object getFieldValue(UserTemplate entity, String fieldName) {
        switch (fieldName) {
            case "userId":
                return entity.getUserId();
            case "templateId":
                return entity.getTemplateId();
            default:
                return super.getFieldValue(entity, fieldName);
        }
    }

    @Override
    public void setFieldValue(UserTemplate entity, String fieldName, Object value) {
        switch (fieldName) {
            case "userId":
                entity.setUserId((java.lang.String) value);
                break;
            case "templateId":
                entity.setTemplateId((java.lang.String) value);
                break;
            default:
                super.setFieldValue(entity, fieldName, value);
                break;
        }
    }

}

